Add option to force buffer closed after certain amount of time
authorjustbur <justin@burkett.cc>
Thu, 2 Jul 2015 02:41:22 +0000 (22:41 -0400)
committerjustbur <justin@burkett.cc>
Thu, 2 Jul 2015 02:41:22 +0000 (22:41 -0400)
which-key.el

index 65a7bd00cb358f51901219bc685cd65867c7b8dc..362491425adc6295caa321cacab88d41a89f918e 100644 (file)
@@ -20,7 +20,7 @@
 (defvar which-key-idle-delay 0.5
   "Delay (in seconds) for which-key buffer to popup.")
 (defvar which-key-close-buffer-idle-delay 5
-  "Delay (in seconds) for which-key buffer to show.")
+  "Delay (in seconds) after which buffer is forced closed.")
 (defvar which-key-max-description-length 30
   "Truncate the description of keys to this length (adds
   \"..\")")
@@ -150,7 +150,8 @@ replace and the cdr is the replacement text. "
           (if bottom-or-top
               (setq buffer-height (+ 2 buffer-line-breaks))
             (setq buffer-width vertical-buffer-width)))
-        (which-key/show-buffer buffer-height buffer-width)))))
+        (which-key/show-buffer buffer-height buffer-width)
+        (run-at-time which-key-close-buffer-idle-delay nil 'which-key/hide-buffer)))))
 
 (defun which-key/setup ()
   "Create buffer for which-key and add buffer to `popwin:special-display-config'"
@@ -165,6 +166,11 @@ replace and the cdr is the replacement text. "
    :noselect t
    :position which-key-buffer-position))
 
+(defun which-key/hide-buffer ()
+  "Like it says :\)"
+  (when (eq popwin:popup-buffer (get-buffer which-key-buffer))
+    (popwin:close-popup-window)))
+
 (defun which-key/turn-on-timer ()
   "Activate idle timer."
   (setq which-key-timer